package com.xbjtech.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.xbjtech.mapper.ResourceMapper;
import com.xbjtech.model.Resource;
import com.xbjtech.model.ResourceExample;
import com.xbjtech.service.ResourceService;

/**
* @author sparkCat E-mail:2925365275@qq.com
* @version 创建时间：2019年1月31日 下午7:46:32
* 类说明
*/
@Service
public class ResourceServiceImpl implements ResourceService {

	@Autowired
	ResourceMapper resourceMapper;
	
	@Override
	public List<Resource> list(ResourceExample example, Integer page, Integer rows) {
		PageHelper.startPage(page, rows);
		return resourceMapper.selectByExample(example);
	}

	@Override
	public void insertResource(Resource resource) throws Exception {
		resourceMapper.insert(resource);
	}

	@Override
	public void updateResource(Resource resource) throws Exception {
		resourceMapper.updateByPrimaryKeySelective(resource);
	}

	@Override
	public void deleteResourceById(Long id) throws Exception {
		resourceMapper.deleteByPrimaryKey(id);
	}

	@Override
	public List<Resource> getAllResource() throws Exception {
		return resourceMapper.selectByExample(null);
	}

}
